package com.amiral.kupluk;


import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.SharedPreferences;
import android.widget.RemoteViews;

public class Widget extends AppWidgetProvider{
	
	public static final String JADWAL="jadwal";
	
	Activity activity;
		
	public int jSubuh;
	public int mSubuh;
	public int jZuhur;
	public int mZuhur;
	public int jAshar;
	public int mAshar;
	public int jMaghrib;
	public int mMaghrib;
	public int jIsya;
	public int mIsya;
    
	
	@Override
	public void onUpdate(Context context,AppWidgetManager appWidgetManager, int[] appWidgetIds){
		//inisialisasi tanggal
		SharedPreferences sharedPreferences= activity.getSharedPreferences(JADWAL, 0);
		 jSubuh=sharedPreferences.getInt("jSubuh", 4);
		 mSubuh=sharedPreferences.getInt("mSubuh", 10);
		 jZuhur = sharedPreferences.getInt("jZuhur", 1);
		 mZuhur= sharedPreferences.getInt("mZuhur", 1);
		 jAshar=sharedPreferences.getInt("jAshar", 1);
		 mAshar=sharedPreferences.getInt("mAshar", 1);
		 jMaghrib=sharedPreferences.getInt("jMaghrib", 1);
		 mMaghrib=sharedPreferences.getInt("mMaghrib", 1);
		 jIsya=sharedPreferences.getInt("jIsya", 1);
		 mIsya=sharedPreferences.getInt("mIsya", 1);
	      
	      RemoteViews updateView= new RemoteViews(context.getPackageName(), R.layout.widgetmain);
	      updateView.setTextViewText(R.id.wg_jamsubuh, jSubuh+":"+mSubuh);
	      updateView.setTextViewText(R.id.wg_jamzuhur, jZuhur+":"+mSubuh);
	      updateView.setTextViewText(R.id.wg_jamashar, jAshar+":"+mSubuh);
	      updateView.setTextViewText(R.id.wg_jammaghrib, jMaghrib+":"+mMaghrib);
	      updateView.setTextViewText(R.id.wg_jamisya, jIsya+":"+mIsya);
	      
	      appWidgetManager.updateAppWidget(appWidgetIds, updateView);
	      super.onUpdate(context, appWidgetManager, appWidgetIds);
	}

	

}
